<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>二手房</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 引入YDUI样式 -->
    <link rel="stylesheet" href="../build/css/ydui.css" />
	<link rel="stylesheet" href="../css/common.css" />
	<link rel="stylesheet" href="../css/fontcss/css/font-awesome.min.css" />
    <!-- 引入YDUI自适应解决方案类库 -->
    <script src="../build/js/ydui.flexible.js"></script>
	<style>
	.item-list{
		padding: .3rem;
	}
	.item-list .left-img{
		width: 3rem;
		height: 2rem;
		margin: 0 .2rem 0 0;
		float: left;
	}
	img{
		width: 100%;
		height: 100%;
	}
	.desc-right .desc-title{
		padding: 0 0 .1rem 0;
	}
	.desc-right p{
		padding: .1rem 0 0 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.desc-right .desc-address{
		color:#5D5D5D ;
	}
	.desc-right .desc-content{
		color:#898989 ;
		display: inline-block;
	}
	.desc-right{
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
	}
	.desc-right span a{
		padding: .05rem 0;
		color: #C1060F;
		display: inline-block;
	}
	.desc-right .yong{
		padding: .02rem .2rem;
		color:#fff;
		background: #FF9966;
		border-radius: .1rem;
	}
	p.desc-tip{
		padding: .1rem 0;
	}
	</style>
</head>
<body>
	<section class="g-flexview">
		<!-- 顶部内容 -->
		<header class="m-navbar">
			<a href="#" onClick="javascript :window.history.back(); return false;" class="navbar-item">
				<i class="back-ico"></i>
			</a>
			<div class="navbar-center">
				<span class="navbar-title">二手房源</span>
			</div>
		</header>
		
		<!-- 二手房源列表 -->
		<div class="g-scrollview">
			<div class="g-scrollview" id="getoldlist"></div>
		</div>
		<!-- 发布按钮 -->
		<a href="./release.html">
			<div id="release">发布</div>
		</a>
		<!-- 报备客户按钮 -->
		<!-- <a href="reportecustomers/index.html">
			<div id="preparation">报备</div>
		</a> -->
		<!-- 底部导航 -->
		<footer class="m-tabbar">
			<a href="../index.html" class="tabbar-item">
				<span class="tabbar-icon">
					<i class="fa fa-home"></i>
				</span>
				<span class="tabbar-txt">首页</span>
			</a>
			<a id="newhouseclick" href="#" class="tabbar-item">
				<span class="tabbar-icon">
					<i class="icon-home"></i>
				</span>
				<span class="tabbar-txt">新房分销</span>
			</a>
			<a href="#" class="tabbar-item tabbar-active">
				<span class="tabbar-icon">
					<i class="fa fa-institution"></i>
				</span>
				<span class="tabbar-txt">二手房</span>
			</a>
			<a id="mine" href="#" class="tabbar-item">
				<span class="tabbar-icon">
					<i class="icon-ucenter-outline"></i>
				</span>
				<span class="tabbar-txt">我的</span>
			</a>
		</footer>
</section>
<!-- 引入jQuery 3.0+ -->
<script src="../js/jq331.min.js"></script>
<!-- 引入YDUI脚本 -->
<script src="../build/js/ydui.js"></script>
<script src="../js/common.js"></script>
<script src="../js/template.js"></script>
<!-- <script src="../js/Index.js"></script> -->
<script id="oldhouselist" type="text/html">
	{{each data as value index}}
		<a href="olddetails.html?id={{data[index].id}}">
			<div class="item-list" data="{{data[index].id}}">
				<div class="left-img">
					<img src="{{data[index].cover_img.img_url}}" />
				</div>
				<div class="desc-right">
					<p class="desc-title"><p style="font-size: .3rem;">{{data[index].title}}</p><span><a>{{data[index].house_price}}&nbsp元/㎡</a></span></p>
					<p class="desc-address">{{data[index].house_address}}</p>
					<p class="desc-tip">
						{{each data[index].decoration_type as item id}}
						<label class="yong">{{item}}</label>
						{{/each}}
					</p>				
				</div>
			</div>
		</a>
	{{/each}}
	
</script>
<script>
	$(document).ready(function(){
		var getnewhouseApi = commapi + "house/list";
		var page = 1, limit = 100;
		var province =  decodeURI(GetQueryString('province'));
		var city =   decodeURI(GetQueryString('city'));
		//var area = decodeURI(GetQueryString('area'));
		$.ajax({
				url: getnewhouseApi,
				type: 'GET',									
				data: {'page': page, 'limit': limit, 'province': province, 'city': city,'area':'', 'type': 2},											
				success: function (ret) {	
					console.log(ret)
					if(ret.total==0){						
						$('#getoldlist').html("<img style='max-width: 100%;height: auto;' src='../static/images/nodata.png' />");
					}else{
						var html = template('oldhouselist', {data: ret.data});
						$('#getoldlist').html(html);
					}
				}
				});
		//进入新房
		$('#newhouseclick').click(function(){
			var province = decodeURI(GetQueryString('province'));
			var city = decodeURI(GetQueryString('city'));
			console.log(city)
			location.href="./newhouse.html?province="+ encodeURI(province)+'&'+'city='+encodeURI(city);
		});
		
		//进入我的
		$('#mine').click(function(){
			var province = decodeURI(GetQueryString('province'));
			var city = decodeURI(GetQueryString('city'));
			console.log(city)
			location.href="./percenter.html?province="+ encodeURI(province)+'&'+'city='+encodeURI(city);
		});
	});
</script>
</body>
</html>